import { LayFull, LayView } from "@/layouts";
import { routePath } from "@/tools";

const baseRoutes = [
	{
		component: routePath("user"),
		hidden: true,
		meta: {
			title: "个人信息"
		},
		name: "User",
		path: "user"
	},
	{
		component: routePath("config"),
		hidden: true,
		meta: {
			title: "系统设置"
		},
		name: "Config",
		path: "config"
	},
	{
		component: routePath("error"),
		hidden: true,
		meta: {
			title: "系统错误"
		},
		name: "Error",
		path: "error"
	}
];

const adminRoutes = [
	{
		component: routePath("admin/user"),
		meta: {
			title: "人员管理"
		},
		name: "AdminUser",
		path: "user"
	},
	{
		component: routePath("admin/role"),
		meta: {
			title: "角色管理"
		},
		name: "AdminRole",
		path: "role"
	}
];

const dataRoutes = [
	{
		component: routePath("data/v-chart"),
		meta: {
			title: "VChart"
		},
		name: "VChart",
		path: "v-chart"
	}
];

export const childRoutes = [
	{
		component: routePath("dash"),
		meta: {
			icon: "el-icon-s-marketing",
			title: "控制台"
		},
		name: "Dash",
		path: "/dash"
	},
	{
		children: adminRoutes,
		component: LayView,
		meta: {
			icon: "el-icon-s-help",
			title: "管理中心"
		},
		name: "Admin",
		path: "/admin",
		redirect: `/admin/${adminRoutes[0].path}`
	},
	{
		children: dataRoutes,
		component: LayView,
		meta: {
			icon: "el-icon-s-data",
			title: "数据管理"
		},
		name: "Data",
		path: "/data",
		redirect: `/data/${dataRoutes[0].path}`
	},
	...baseRoutes
];

export default [
	{
		component: routePath("login"),
		meta: {
			title: "系统登录"
		},
		name: "Login",
		path: "/login"
	},
	{
		children: childRoutes,
		component: LayFull,
		name: "Layout",
		path: "/",
		redirect: childRoutes[0].path
	},
	{
		path: "/:pathMatch(.*)",
		redirect: "/error"
	}
];
